package com.xoa.controller.performance;

import com.xoa.dao.common.SysCodeMapper;
import com.xoa.model.common.SysCode;
import com.xoa.model.performance.ScoreGroup;
import com.xoa.model.performance.ScoreGroupWithBLOBs;
import com.xoa.service.performance.ScoreGroupService;
import com.xoa.util.ToJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("/ScoreGroupController")
/**
 * 指标集设定
 */
public class ScoreGroupController {
    @Autowired
    private ScoreGroupService scoreGroupService;
    @Autowired
    private SysCodeMapper sysCodeMapper;
    @RequestMapping("/scoreGroup")
    public String scoreGroup() {
        return "app/hr/assessment";
    }
    @RequestMapping("/assessmentbianji")
    public String score() {
        return "app/hr/assessmentbianji";
    }

    //进行考核页面
    @RequestMapping("/score")
    public String assessmenting(){
        return "app/hr/assessmenting";
    }

    /**
     * 郭心雨
     * 2018.6.21
     * 添加指标集
     * @param scoreGroup
     * @return
     */
    @RequestMapping("/addScoreGroup")
    @ResponseBody
    public ToJson addScoreGroup(ScoreGroupWithBLOBs scoreGroup, HttpServletRequest request){

        return scoreGroupService.addScoreGroup(scoreGroup,request);
    }

    /**
     * 郭心雨
     * 2018.6.21
     * 删除指标集
     * @param groupId
     * @return
     */
    @RequestMapping("/delScoreGroupById")
    @ResponseBody
    public ToJson delScoreGroupById(Integer groupId){
        return scoreGroupService.delScoreGroupById(groupId);
    }

    /**
     * 郭心雨
     * 2018.6.21
     * 修改指标集
     * @param scoreGroup
     * @return
     */
    @RequestMapping("/modifyScoreGroup")
    @ResponseBody
    public ToJson modifyScoreGroup(ScoreGroupWithBLOBs scoreGroup){
        return scoreGroupService.modifyScoreGroup(scoreGroup);
    }

    /**
     * 郭心雨
     * 2018.6.21
     * 动态查询指标集
     * @param scoreGroup
     * @return
     */
    @RequestMapping("/selScoreGroup")
    @ResponseBody
    public ToJson selScoreGroup(ScoreGroupWithBLOBs scoreGroup,@RequestParam(value = "page",required = false) Integer page,
                                @RequestParam(value = "pageSize",required = false) Integer pageSize,
                                @RequestParam(value="useFlag",required = false) Boolean useFlag){
        return scoreGroupService.selScoreGroup(scoreGroup, page, pageSize, useFlag);
    }

    /**
     * 郭心雨
     * 2018.06.25
     * 查看考核项目类型列表
     * @param parentNo
     * @return
     */
    @RequestMapping("/getChildCode")
    @ResponseBody
    private ToJson getChildCode(String parentNo){
        return scoreGroupService.getChildCode(parentNo);
    }

    /**
     * @接口说明: 克隆功能接口
     * @日期: 2020/7/31
     * @作者: 张航宁
     */
    @RequestMapping("/cloneScoreGroup")
    @ResponseBody
    public ToJson cloneScoreGroup(Integer groupId, HttpServletRequest request){
        return scoreGroupService.cloneScoreGroup(groupId,request);
    }
}
